<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0;" name="viewport" />
    <meta http-equiv="X-UA-Compatible" content="ie=edge" />
    <title>h5禁止缩放</title>
  </head>
  <body>
    <h3>这是一个寂寞的天</h3>
    <script>
      window.onload = function() {
        document.addEventListener("touchstart", function(event) {
          if (event.touches.length > 1) {
            event.preventDefault();
          }
        });
        var lastTouchEnd = 0;
        document.addEventListener(
          "touchend",
          function(event) {
            var now = new Date().getTime();
            if (now - lastTouchEnd <= 300) {
              event.preventDefault();
            }
            lastTouchEnd = now;
          },
          false
        );
        document.addEventListener("gesturestart", function(event) {
          event.preventDefault();
        });
      };
    </script>
  </body>
</html>
